%18-March-2008. these scripts were used to correct the NGRi wdc files
% refer to emails Don Herzog on this day
%the corrected files are stored in project/hyd_ett-check/ETT.zip & HYB.zip
%It seems the element parameter is not in the correct column for loading
%into SPIDR. The element (H,D,Z. etc.) should be in column 8, but in the files I received, it is in column 12.
%The Q's and D's in column 15 should be expressed as numbers. Q=1 and D=2.
%One other point. The element (H, D, Z) is still in column 12, whereas
%column 11 and 12 should be blank. Can you correct this as well? 
%further don wrote on 4/16/2008 9:10 AM ->
%And columns 15-16 calls for the century code, "20" for years 2000 and
%beyond. 
kk = dir('C:\Manoj\projects\hybett_check\temp\*.WDC');

for i = 1:length(kk),
    fid = fopen(['C:\Manoj\projects\hybett_check\temp\' kk(i).name],'rt');
    fid1 = fopen(['C:\Manoj\projects\hybett_check\temp\new\' kk(i).name],'wt');
    flag = 1;
    while flag == 1,
    S = fgets(fid);
    if S == -1,
        flag =0;
        break;
    end;
    switch S(8),
    case '1',
        S(8) = 'D';
    case '3',
        S(8) = 'H';
    case '7',
        S(8) = 'Z';
    case 'D',
        S(8) = 'D';
    case 'H',
        S(8) = 'H';
    case 'Z',
        S(8) = 'Z';
    otherwise,
        fprintf('unknown element in %s\n',kk(i).name);
   
    end;
%    switch S(15),
%        case 'Q',
            S(16) = '0';
 %       case 'D',
            S(15) = '2';
  %  end;
    S(12) = ' ';
    fprintf(fid1,'%s',S);
    end;
    fclose all;
end;
    
%zip('HYB','*.WDC')